/**
 * @param {number[]} nums
 * @param {number} k
 * @return {number[]}
 */
 var maxSubsequence = function(nums, k) {
  let arr = [...nums]
  arr.sort((a,b) => b-a)
  const map = new Map()
  for(let i = 0; i<k; i++){
    map.set(arr[i], (map.get(arr[i]) || 0) + 1)
  }
  let ans = []
  for(let x of nums){
    if(map.has(x) && map.get(x) >= 1){
      ans.push(x)
      map.set(x, map.get(x)-1)
    }
  }
  return ans
}